package com.caipiao.lottery.config;

/**
 * @author GaoFeng
 */

import java.io.File;

import org.slf4j.LoggerFactory;

import com.caipiao.lottery.log.TraceLogger;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;

public class LoggerConfig extends ConfigInterface
{
	public LoggerConfig(String name)
	{
		this.ConfigName = name;
	}
	
	@Override
	public boolean ReLoad()
	{
        try
        {
        	File cfgFile = new File(this.FilePath);
        	
        	this.lastModify= cfgFile.lastModified();

    		LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        	loggerContext.reset();
        	JoranConfigurator configurator = new JoranConfigurator();
        	configurator.setContext(loggerContext);
        	configurator.doConfigure(this.FilePath);
        	
        	TraceLogger.System.debug(this.ConfigName + "加载完成:" + FilePath);

            return true;
        }
        catch (Exception e)
        {
        	TraceLogger.System.error(this.ConfigName + "加载异常:" + FilePath + "|" + e.toString(), e);
        	 return false;
        }
	}
}
